<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>后台管理</title>
    <base href="http://localhost/campus/">
    <link rel="shortcut icon" href="static/favicon.ico" type="image/x-icon"/>
    <link rel="stylesheet" type="text/css" href="layui/css/layui.css"/>
    <link rel="stylesheet" type="text/css" href="static/css/admin.css"/>
    <script src="static/js/jquery.min.js"></script>
    <script src="layui/layui.js"></script>
    <script src="layui/extends/steps.js"></script>
</head>
<body>
<div class="layui-fluid">

    <%--头部信息--%>
    <%@include file="/pages/common/adminHeader.jsp" %>

    <div class="layui-row center">

        <%--左边菜单栏--%>
        <div class="layui-col-xs2 layui-col-sm2 layui-col-md2">
            <div class="admin_menu">
                <ul class="layui-nav layui-nav-tree layui-inline" lay-shrink="all"
                    lay-filter="adminMenuTab"
                    style="margin-right: 10px;background: #797979">
                    <li class="layui-nav-item layui-nav-itemed">
                        <a href="javascript:;">用户管理</a>
                        <dl class="layui-nav-child">
                            <dd><a href="javascript:;" style="background: #8F908E;">添加管理员</a></dd>
                            <dd><a href="javascript:;" style="background: #8F908E;">删除管理员</a></dd>
                        </dl>
                    </li>
                    <li class="layui-nav-item" lay-filter="adminMenuTab">
                        <a href="javascript:;">商品管理</a>
                        <dl class="layui-nav-child">
                            <dd><a href="javascript:;" style="background: #8F908E;">商品分类管理</a></dd>
                            <dd><a href="javascript:;" style="background: #8F908E;">商品信息管理</a></dd>
                        </dl>
                    </li>
                    <li class="layui-nav-item"><a href="javascript:;" style="background: #797979;">留言管理</a></li>
                    <li class="layui-nav-item"><a href="javascript:;" style="background: #797979;">物流管理</a></li>
                    <li class="layui-nav-item">
                        <a href="javascript:;" style="background: #797979;">查看报表</a>
                        <dl class="layui-nav-child">
                            <dd><a href="javascript:;" style="background: #8F908E;">用户报表</a></dd>
                            <dd><a href="javascript:;" style="background: #8F908E;">商品报表</a></dd>
                            <dd><a href="javascript:;" style="background: #8F908E;">订单报表</a></dd>
                        </dl>
                    </li>
                </ul>
            </div>
        </div>

        <div class="layui-col-xs10 layui-col-sm10 layui-col-md10">
            <div class="menu_content">
                <div class="menu_content_top">
                    <span class="layui-breadcrumb breadcrumb">
                      <a id="breadcrumb1">用户管理</a>
                      <a id="breadcrumb2"><cite>添加管理员</cite></a>
                    </span>
                    <img src="${sessionScope.user.avatar}">
                    <p>欢迎你,${sessionScope.user.username}</p>
                </div>

                <div class="menu_content_centre" id="menu_content_centre">

                </div>
            </div>
        </div>
    </div>

    <%@include file="/pages/common/footer.jsp" %>
</div>
<script>
    //注意：导航 依赖 element 模块，否则无法进行功能性操作
    layui.use('element', function () {
        var element = layui.element;
        let url = "";
        element.on('nav(adminMenuTab)', function (elem) {
            let text = elem.context.text; //得到当前导航栏的内容
            let bread = $("#breadcrumb1");
            $(bread).css("display", "inline");
            switch (text) {
                case "添加管理员":
                    url = "http://localhost/campus/userAdd";
                    $(bread).text("用户管理");
                    break;
                case "删除管理员":
                    url = "http://localhost/campus/userDelete";
                    $(bread).text("用户管理");
                    break;
                case "商品分类管理":
                    url = "http://localhost/campus/productCategory";
                    $(bread).text("商品管理");
                    break;
                case "商品信息管理":
                    url = "http://localhost/campus/productInfo";
                    $(bread).text("商品管理");
                    break;
                case "留言管理":
                    url = "http://localhost/campus/messageAdmin";
                    $(bread).css("display", "none");
                    break;
                case "物流管理":
                    url = "http://localhost/campus/orderAdmin";
                    $(bread).css("display", "none");
                    break;
                case "用户报表":
                    url = "http://localhost/campus/reportsUser";
                    $(bread).text("查看报表");
                    break;
                case "商品报表":
                    url = "http://localhost/campus/reportsProduct";
                    $(bread).text("查看报表");
                    break;
                case "订单报表":
                    url = "http://localhost/campus/reportsOrder";
                    $(bread).text("查看报表");
                    break;
                default:
                    return false;
            }
            $("#breadcrumb2").text(text);
            element.render('breadcrumb');
            if (url !== "")
                $.ajax({
                    url: url
                    , type: "GET"
                    , success: function (data) {
                        $('#menu_content_centre').html(data);
                    }
                    , error: function (e) {

                    }
                });
        });
    });

    $.ajax({
        url: 'http://localhost/campus/userAdd'
        , type: "GET"
        , success: function (data) {
            $('#menu_content_centre').html(data);
        }
        , error: function (e) {

        }
    });

</script>
</body>
</html>
